CopyTo Method

Task Parallel System.Threading

Copies the ConcurrentBag<(Of <(T>)>) elements to an existing one-dimensional Array, starting at the specified array index.

Namespace:  System.Collections.Concurrent
Assembly:  System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub CopyTo ( _
	array As T(), _
	index As Integer _
)
C#
public void CopyTo(
	T[] array,
	int index
)

Parameters

array
Type: array< T >[]()[]
The one-dimensional Array that is the destination of the elements copied from the ConcurrentBag<(Of <(T>)>). The Array must have zero-based indexing.
index
Type: System..::.Int32
The zero-based index in array at which copying begins.

Implements

IProducerConsumerCollection<(Of <(T>)>)..::.CopyTo(array<T>[]()[], Int32)

Exceptions

ExceptionCondition
System..::.ArgumentNullExceptionarray is a null reference (Nothing in Visual Basic).
System..::.ArgumentOutOfRangeExceptionindex is less than zero.
System..::.ArgumentExceptionindex is equal to or greater than the length of the array -or- the number of elements in the source ConcurrentBag<(Of <(T>)>) is greater than the available space from index to the end of the destination array.

See Also